using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using DynSim.EntityFramework;
using JigLibX;
using JigLibX.Physics;
using JigLibX.Collision;
using JigLibX.Geometry;
using JigLibX.Math;

namespace DynSim.Basics
{
    public class Physics : GameComponent
    {
        PhysicsSystem system;

        BaseEngine engine;

        public Physics(BaseEngine engine, Game game)
            : base(game)
        {
            
            system = new PhysicsSystem();
            system.CollisionSystem = new CollisionSystemSAP();

            game.Components.Add(this);

            this.engine = engine;
        }

        public void ApplyPhysics(IModel model)
        {
            system.AddBody(new ModelBody(model));
        }

        public override void Update(GameTime gameTime)
        {
            float timeStep = (float)gameTime.ElapsedGameTime.Ticks / TimeSpan.TicksPerSecond;
            system.Integrate(timeStep);
            
            base.Update(gameTime);
        }
    }

    internal class ModelBody : Body
    {
        public ModelBody(IModel model)
        {
            
        }
    }
}
